package com.lhc.springboot_mybatispuls.controller;

import com.lhc.springboot_mybatispuls.entity.DomeUser;
import com.lhc.springboot_mybatispuls.service.UserService;
import com.lhc.springboot_mybatispuls.util.OutputObject;
import com.lhc.springboot_mybatispuls.util.ReturnCode;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName UserController
 * @Description:
 * @Author: Lhc
 * @CreateDate: 2020-11-26 10:57
 * @UpdateUser: asus
 * @UpdateDate: 2020-11-26 10:57
 * @UpdateRemark:
 * @Version: 1.0
 */
@RestController
@RequestMapping(value = "/User")
public class UserController {
    @Autowired
    UserService userService;
    Map<String,String> map = new HashMap<String,String>();
    OutputObject outputObject = new OutputObject();

   @ApiOperation(value="根据用户ID删除用户", notes="id不可为空")
   @RequestMapping(value = "/deleteByPrimaryKey",method = RequestMethod.DELETE)
    public int deleteByPrimaryKey(Integer id) {
        return userService.deleteByPrimaryKey(id);
    }

    @ApiOperation(value="创建新用户", notes="所有字段")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public int insert(DomeUser record) {
        return userService.insert(record);
    }

    @ApiOperation(value="创建新用户", notes="非空字段")
    @RequestMapping(value = "/insertSelective",method = RequestMethod.POST)
    public int insertSelective(DomeUser record) {
        return userService.insertSelective(record);
    }

    @ApiOperation(value="根据用户id查询用户信息", notes="id不可为空")
    @RequestMapping(value = "/selectByPrimaryKey",method = RequestMethod.GET)
    public DomeUser selectByPrimaryKey(Integer id) {
        return userService.selectByPrimaryKey(id);
    }

    @ApiOperation(value="根据用户id修改用户信息", notes="id不可为空,非空字段")
    @RequestMapping(value = "/updateByPrimaryKeySelective",method = RequestMethod.PUT)
    public int updateByPrimaryKeySelective(DomeUser record) {
        return userService.updateByPrimaryKeySelective(record);
    }

    @ApiOperation(value="根据用户id修改用户信息", notes="id不可为空")
    @RequestMapping(value = "/updateByPrimaryKey",method = RequestMethod.PUT)
    public int updateByPrimaryKey(DomeUser record) {
        return userService.updateByPrimaryKey(record);
    }
}
